<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- <link rel="icon" href="../../favicon.ico"> -->

    <title>企业管理</title>

    <!-- Bootstrap core CSS -->
    <link href="./libs/bootstarp/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <!-- <link href="../../assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet"> -->

    <!-- Custom styles for this template -->
    <link href="./css/index.css" rel="stylesheet">
    <link rel="stylesheet" href="./css/enterprise.css">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <!-- <script src="../../assets/js/ie-emulation-modes-warning.js"></script> -->

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- <script src="./libs//template/template-web.js"></script> -->
    <style>
        [v-cloak] {
            display: none !important;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <zdy-nav title="企业管理" :nav-list="navList"></zdy-nav>

        <div class="container">
            <div class="row enterprise-main">
                <div class="col-md-12">
                    <div class="enter-header">
                        <div>
                            <input type="file" style="display: none;" ref="file" @change="handleOnChange">
                            <img :src="picPath" width="100px" height="100px" alt="" @click="handleOnClickImg">
                        </div>
                        <div style="flex:1;">
                            <div class="enter-title">
                                <button v-if="titleShow" class="btn btn-info enter-btn"
                                    @click="titleShow = false">编辑</button>
                                <h2 v-if="titleShow">{{options.name}}</h2>
                                <form class="form-inline enter-title-editor" v-if="!titleShow">
                                    <div class="form-group">
                                        <label for="inputPassword" class="sr-only">公司名称</label>
                                        <input type="text" id="inputPassword" class="form-control" placeholder="请输入公司名称"
                                            required v-model="options.name">
                                    </div>
                                    <button class="btn btn-primary" type="button" @click="handleOnClick">确定</button>
                                    <button class="btn" type="button" @click="titleShow = true">取消</button>
                                </form>
                            </div>

                        </div>

                    </div>
                </div>
                <div class="col-md-12">
                    <div class="enter-desc">
                        <div class="col-md-12">
                            <div class="enter-desc-header" v-if="descShow">公司介绍
                                <button class="btn btn-info" @click="descShow = false">编辑</button>
                            </div>
                            <div v-if="descShow">{{options.info}}</div>
                            <form class="enter-desc-editor" v-if="!descShow">
                                <div class="form-group">
                                    <textarea class="form-control" rows="3" placeholder="请输入公司介绍"
                                        v-model="options.info"></textarea>
                                </div>
                                <button class="btn btn-primary" type="button" @click="handleOnClickDesc">确定</button>
                                <button class="btn" type="button" @click="descShow = true">取消</button>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="enter-job">
                        <div class="col-md-12">
                            <div style="display:flex;justify-content:space-between;">
                                <h3>已发布职位</h3>
                                <!-- <a class="btn btn-primary" href="./addJob.html">发布职位</a> -->
                            </div>
                            <div class="list-group">
                                <div class="lit-group-item zdy-group-item" v-for="item in jobs"
                                    @click="handleOnClickEdit(item)">
                                    <div class="header">
                                        <p class="title">{{item.title}}</p>
                                        <p>{{item.compName}}</p>
                                    </div>
                                    <div class="desc">
                                        <span>{{item.createTime}}</span>
                                        <span>{{item.address}}</span>
                                        <span>{{item.degree}}</span>
                                        <span>{{item.benefits}}</span>
                                    </div>
                                </div>
                            </div>
                            <zdy-page :total="jobSize" @num="handleOnChangeJob"></zdy-page>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="enter-job">
                        <div class="col-md-12">
                            <h3>简历库</h3>
                            <div class="list-group">
                                <div class="lit-group-item zdy-group-item" v-for="item in resumes"
                                    @click="handleOnClickResume(item)">
                                    <div class="header">
                                        <p class="title">{{item.name}}</p>
                                        <p>{{item.shcool}}</p>
                                    </div>
                                    <div class="desc">
                                        <span>{{item.createTime}}</span>
                                        <span>{{item.major}}</span>
                                        <span>{{item.history}}</span>
                                    </div>
                                </div>
                            </div>
                            <zdy-page :total="resumeSize" @num="handleOnChangeResume"></zdy-page>
                        </div>
                    </div>
                </div>
            </div><!-- /.row -->
        </div><!-- /.container -->

        <zdy-footer></zdy-footer>
        <div id="myModal" class="modal fade" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">简历详情</h4>
                    </div>
                    <div class="modal-body">
                        <h4>姓名{{modalOptions.name}}</h4>
                        <p>专业：{{modalOptions.major}}</p>
                        <p>毕业学校：{{modalOptions.shcool}}</p>
                        <p>创建时间：{{modalOptions.createTime}}</p>
                        <p>个人经历：{{modalOptions.history}}</p>
                        <p>意向岗位：{{modalOptions.intention}}</p>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
    </div>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> -->
    <!-- <script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script> -->
    <script src="./libs/jquery/jquery.min.js"></script>
    <script src="./libs/bootstarp/js/bootstrap.js"></script>
    <script src="./libs/vue/vue.js"></script>
    <script src="./tpl/publicTpl.js"></script>
    <script src="./js/utils.js"></script>
    <script src="./js/xhr.js"></script>

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <!-- <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script> -->
    <script>
        var vm = new Vue({
            el: '#app',
            data() {
                return {
                    navList: [
                        { text: '首页', value: 'active', path: './enterprise.html' },
                        { text: '简历库', value: '1', path: './resume.html' },
                        { text: '公司编辑', value: '2', path: './editor.html' },
                        { text: '发布职位', value: '3', path: './addJob.html' }
                    ],
                    titleShow: true,
                    descShow: true,
                    options: {
                        compId: '',
                        logo: '',
                        name: '',
                        info: '',
                        scale: '',
                        address: '',
                        comment: ''
                    },
                    jobList: [],
                    jobs: [],
                    resumeList: [],
                    resumes: [],
                    url: '',
                    modalOptions: {}
                }
            },
            computed: {
                picPath() {
                    return this.url !== '' ? this.url : './img/img_add.png'
                },
                jobSize() {
                    return Math.ceil(this.jobList.length / 10);
                },
                resumeSize() {
                    return Math.ceil(this.resumeList.length / 10);
                }
            },
            created() {
                var self = this;
                var type = getSession('type');
                if (type == 0) {
                    window.location.replace('./index.html')
                }
                var comp = auth();
                if (comp) {
                    var param = {
                        compId: comp.id
                    }
                    xhr.send('/pub/iface/job/getComp', param, function (res) {
                        // self.options = res.comp;
                        self.url = res.comp.logoName !== '' ? res.comp.logo : '';
                        self.options['compId'] = comp.id;
                        self.options['logo'] = res.comp.logoName || '';
                    })
                    xhr.send('/pub/iface/job/getCompJobs', param, function (res) {
                        self.jobList = res.jobs;
                        self.jobs = res.jobs.slice(0, 10);
                    })
                    xhr.send('/pub/iface/job/getUsers', {}, function (res) {
                        self.resumeList = res.users;
                        self.resumes = res.users.slice(0, 10);
                    })
                }
            },
            methods: {
                handleOnClick: function () {
                    var self = this;
                    xhr.send('/pub/iface/job/editComp', this.options, function (res) {
                        self.titleShow = true
                    })
                },
                handleOnClickDesc: function () {
                    var self = this;
                    xhr.send('/pub/iface/job/editComp', this.options, function (res) {
                        self.descShow = true
                    })
                },
                handleOnClickImg: function () {
                    this.$refs.file.click();
                },
                handleOnChange: function (event) {
                    var self = this;
                    var files = event.target.files[0];
                    var fd = new FormData();
                    fd.append('file', files);
                    xhr.upload('/pub/iface/job/upload', fd, function (res) {
                        self.options.logo = res.filename;
                        self.options.logoName = res.filename;
                        self.url = res.url;
                        self.handleOnClick();
                    })
                },
                handleOnClickEdit: function (item) {
                    window.sessionStorage.setItem('jobInfo', JSON.stringify(item));
                    window.location.href = './editJob.html';
                },
                handleOnChangeJob: function (num) {
                    var end = this.jobList.slice(num).length > 10 ? 10 : null;
                    this.jobs = !!end ? this.jobList.slice(num, end) : this.jobList.slice(num)
                },
                handleOnChangeResume: function (num) {
                    var end = this.resumeList.slice(num).length > 10 ? 10 : null;
                    this.jobs = !!end ? this.resumeList.slice(num, end) : this.resumeList.slice(num)
                },
                handleOnClickResume: function (item) {
                    this.modalOptions = item;
                    $('#myModal').modal('show')
                }
            },
        })
    </script>
</body>

</html>